package com.engine.salary.service;

import com.engine.salary.common.LocalDateRange;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
import com.engine.salary.entity.salaryarchive.param.*;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 薪资档案
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public interface SalaryArchiveService {

    /**
     * 获取薪资档案单条主记录
     *
     * @param salaryArchiveId
     * @return
     */
    SalaryArchivePO getById(Long salaryArchiveId);

    List<SalaryArchiveListDTO> getSalaryArchiveList (SalaryArchiveQueryParam queryParam);

    List<SalaryArchivePO> listSome(SalaryArchivePO po);

    /**
     * 薪资档案列表（分页）
     *
     * @param queryParam
     * @return
     */
    PageInfo<SalaryArchiveListDTO> listPage(SalaryArchiveQueryParam queryParam);

    List<SalaryArchiveListDTO> list(SalaryArchiveQueryParam queryParam);

    /**
     * 构建薪资档案数据
     *
     * @param salaryArchives
     * @param taxAgentLists
     * @param salaryItems
     * @param isPage
     * @return
     */
    List<Map<String, Object>> buildSalaryArchiveData(Collection<SalaryArchiveListDTO> salaryArchives, Collection<TaxAgentPO> taxAgentLists, List<SalaryItemPO> salaryItems, Boolean isPage);

    /**
     * 获取薪资档案对应的当前生效的薪资项目
     *
     * @param salaryArchivesIds
     * @return
     */
    List<SalaryArchiveItemPO> getCurrentEffectiveItemList(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds);

    /**
     * 获取薪资档案对应的当前生效的个税扣缴义务人
     *
     * @param salaryArchivesIds
     * @return
     */
    List<SalaryArchiveTaxAgentPO> getCurrentEffectiveTaxAgentList(Collection<Long> salaryArchivesIds);

    /**
     * 导出薪资档案列表
     *
     * @param queryParam
     * @throws Exception
     */
    XSSFWorkbook exportList(SalaryArchiveQueryParam queryParam);


    /**
     * 保存发薪设置
     *
     * @param saveParam
     * @return
     */
    String savePaySet(SalaryArchiveSetPaySaveParam saveParam);

    /**
     * 获取离职时段设置
     */
    List<SalaryArchiveDimissionPO> dimissionSets();

    /**
     * 保存离职时段设置
     *
     * @param saveParam
     * @return
     */
    String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam);

    /**
     * 根据日期范围与人员id获取薪资档案-薪资项目数据
     *
     * @param localDateRange
     * @param employeeIds    为空则返回所有人的
     * @return
     */
    List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds);

    /**
     * 根据日期范围与人员id获取薪资档案-个税扣缴义务人数据
     *
     * @param localDateRange
     * @param employeeIds    为空则返回所有人的
     * @return
     */
    List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds);

    /**
     * 预览
     * @param param
     * @return
     */
    Map<String, Object> preview(SalaryArchiveImportHandleParam param);

    /**
     * 查询薪酬档案所有列名
     * @return
     */
    Map<String, Object> selectSalaryArchiveColumns(SalaryArchiveImportTypeEnum salaryArchiveImportTypeEnum);

    /**
     * 停薪
     * @param stopSalaryParam
     */
    void stopSalary(SalaryArchiveStopParam stopSalaryParam);

    /**
     * 获取各tab总人数
     *
     * @return
     */
    Map<String, Long> queryTabTotal();


    /**
     * 删除待定薪待办
     *
     * @param ids
     * @return
     */
    String deletePendingTodo(Collection<Long> ids);

    /**
     * 设为定薪员工
     *
     * @param ids
     * @return
     */
    Map<String, Object> gotoFixed(Collection<Long> ids);

    /**
     * 一键全部定薪
     *
     * @param queryParam
     * @return
     */
    Map<String, Object> allGotoFixed(SalaryArchiveQueryParam queryParam);

//    /**
//     * 删除待定薪待办
//     *
//     * @param ids
//     * @return
//     */
//    String deletePendingTodo(Collection<Long> ids);

    /**
     * 停薪
     *
     * @param ids
     * @return
     */
    Map<String, Object> gotoStop(Collection<Long> ids);

    /**
     * 一键全部停薪
     *
     * @param queryParam
     * @return
     */
    Map<String, Object> allGotoStop(SalaryArchiveQueryParam queryParam);

    /**
     * 删除待停薪待办
     *
     * @param ids
     * @return
     */
    String deleteSuspendTodo(Collection<Long> ids);

    /**
     * 取消停薪
     *
     * @param ids
     * @return
     */
    String cancelStop(Collection<Long> ids);


    /**
     * 处理异常数据
     */
    Map<String, Object> handleRepeatData();

    /**
     * 处理增量数据
     * @param currentEmployeeId
     */
    void handleChangeData(Long currentEmployeeId);

    /**
     * 删除薪资档案
     * @param salaryArchiveIds
     */
    void deleteSalaryArchive(Collection<Long> salaryArchiveIds);

    /**
     * 根据人员id查询薪资档案
     * @param employeeIds
     * @return
     */
    List<SalaryArchivePO> listPayEndDateIsNull(List<Long> employeeIds);

    List<SalaryArchivePO> listByRunStatus(List<String> asList);

    /**
     * 同步所有档案起始发薪日期变为入职日期
     *
     * @return
     */
    String syncPayStartDate();

    /**
     * 根据列表状态获取起始发薪日期为空的薪资档案
     * @param runStatus
     * @return
     */
    List<SalaryArchivePO> listPayStartDateIsNull(String runStatus);
}
